package guiLayer;

import guiLayer.extensions.OwnerTableModel;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import modelLayer.Owner;
import controlerLayer.OwnerCtr;

public class OwnerPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private JTable table;
	private ArrayList<Owner> owners;

	/**
	 * Create the panel.
	 */
	public OwnerPanel() {
		OwnerCtr oCtr = new OwnerCtr();
		owners = oCtr.getAllOwners();
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{521, 193, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JPanel panel = new JPanel();
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(0, 0, 0, 5);
		gbc_panel.fill = GridBagConstraints.BOTH;
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 0;
		add(panel, gbc_panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		JLabel lblOwners = new JLabel("Owners");
		lblOwners.setFont(new Font("SansSerif", Font.BOLD, 14));
		panel.add(lblOwners, BorderLayout.NORTH);
		
		OwnerTableModel model = new OwnerTableModel(owners);
		table = new JTable(model);
		table.getColumnModel().getColumn(0).setMaxWidth(25);
		panel.add(new JScrollPane(table), BorderLayout.CENTER);
		
		JPanel panel_1 = new JPanel();
		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
		gbc_panel_1.fill = GridBagConstraints.BOTH;
		gbc_panel_1.gridx = 1;
		gbc_panel_1.gridy = 0;
		add(panel_1, gbc_panel_1);
		
	}
	
}
